import {AlertController} from "ionic-angular";
/**
 * Created by Administrator on 2018/1/13.
 * 使用之前在app.scss中加入以下样式
 .alert-md .alert-head {
  text-align: center;
  padding-top: 10px;
  font-weight: 300;
}

 .alert-md .alert-title {
  font-size: 18px;
}

 .alert-md .alert-sub-title {
  font-size: 18px;
}

 .alert-md .alert-button-group {
  -webkit-flex-wrap: wrap-reverse;
  -ms-flex-wrap: wrap-reverse;
  flex-wrap: wrap-reverse;
  -webkit-box-pack: end;
  -webkit-justify-content: center;
  -ms-flex-pack: end;
  justify-content: center;
  padding: 8px 8px 8px 24px;
}

 .alert-md .alert-button {
  text-align: center;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
  font-weight: 500;
  text-transform: uppercase;
  color: #666666;
  background-color: transparent;
  margin: 0 8px 0 0;
  padding: 10px;
  flex: 1;
}

 .alert-md .alert-button .button-inner {
  -webkit-box-pack: end;
  -webkit-justify-content: center;
  -ms-flex-pack: end;
  justify-content: center;
}

 .alert-md .alert-button.ok {
  background-color: #007aff;
  color: white;
}
 */

export class WgAlert{
  public static alertCtrl: AlertController;

  /* 带Input的提示框 */
  public static inputAlert(message){
    let prompt = this.alertCtrl.create({
      title: 'Login',
      message: "Enter a name for this new album you're so keen on adding",
      inputs: [
        {
          name: 'title',
          placeholder: 'Title'
        },
      ],
      buttons: [
        {
          text: '取消',
          handler: data => {
            console.log('Cancel clicked');
          }
        },
        {
          text: '确定',
          cssClass: 'ok',
          handler: data => {
            message(data.title);
          }
        }
      ]
    });
    prompt.present();
  }

  /* 带确认提示框 : mTitle-- 标题 callBack: O--确认，1--取消*/
  public static confirmAlert(mTitle, callBack){
    let prompt = this.alertCtrl.create({
      title: mTitle,
      buttons: [
        {
          text: '取消',
          handler: data => {
            console.log('Cancel clicked');
            callBack(1);
          }
        },
        {
          text: '确定',
          cssClass: 'ok',
          handler: data => {
            console.log('Confirm clicked');
            callBack(0);
          }
        }
      ]
    });
    prompt.present();
  }

}
